<?php
$script = "
$('#Site_status').click(function(){
    if ($('#Site_status').attr('checked'))
        $('#Site_default').parents('.row').show();
    else
        $('#Site_default').attr('checked', false).parents('.row').hide();
});
if ($('#Site_status').attr('checked'))
    $('#Site_default').parents('.row').show();
else
    $('#Site_default').parents('.row').hide();
";
Yii::app()->clientScript->registerScript(__CLASS__.'#SetDefault', $script, CClientScript::POS_READY);
if ($model->default) {
    $script = "\$('#Site_status').parents('.row').hide();\$('#Site_default').parents('.row').hide();";
    Yii::app()->clientScript->registerScript(__CLASS__.'#DisableChangeDefault', $script, CClientScript::POS_READY);
}
?>
<div class="form wide">

<?php $form=$this->beginWidget('FActiveForm', array(
	'id'=>'site-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

    <?php if (! $model->IsNewRecord) echo $form->hiddenField($model, "id") ; ?>
    <div class="row">
        <?php echo $form->labelEx($model,'name'); ?>
        <?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>100)); ?>
        <?php echo $form->error($model,'name'); ?>
    </div>
    
	<div class="row">
		<?php echo $form->labelEx($model,'locale_id'); ?>
		<?php echo $form->dropDownlist($model,'locale_id', $model->getLocaleIDOptions(),array('prompt'=>'---Default(English)---')); ?>
		<?php echo $form->error($model,'locale_id'); ?>
	</div>
    
    <div class="row">
        <label>Favorite icon</label>
        <div class="actions">
        <?php $this->widget('Admin.components.FileWidget', array(
            'model'=>$model,
            'attribute'=>'fav_icon',
            'root'=>'uploads/',
            'showButtonRemove'=>true,
            'ext'=>array('gif', 'png', 'jpeg', 'jpg','ico'),
        )); ?>
        </div>
    </div>

	<div class="row">
		<?php echo $form->labelEx($model,'status', array('label'=>Yii::t('app', 'Active'))); ?>
		<?php echo $form->checkBox($model,'status'); ?>
		<?php echo $form->error($model,'status'); ?>
	</div>

    <div class="row">
        <?php echo $form->labelEx($model,'default'); ?>
        <?php echo $form->checkBox($model,'default'); ?>
        <?php echo $form->error($model,'default'); ?>
    </div>

    <?php if ($model->isNewRecord):?>
    <div class="row">
        <?php echo $form->labelEx($model,'urls'); ?>
        <?php echo $form->textArea($model,'urls', array('cols'=>70, 'rows'=>7)); ?>
        <?php echo $form->error($model,'urls'); ?>
    </div>
    <?php else:?>
	<div class="row">
        <?php echo $form->labelEx($model,'creation_datetime'); ?>
		<?php echo Yii::app()->getDateFormatter()->formatDateTime(strtotime($model->creation_datetime)); ?>
	</div>

	<div class="row">
        <?php echo $form->labelEx($model,'last_update'); ?>
		<?php echo Yii::app()->getDateFormatter()->formatDateTime(strtotime($model->last_update)); ?>
	</div>
    <?php endif;?>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->